import networkx as nx
import matplotlib.pyplot as plt


def main():
    G = nx.Graph()

    # topology construction logic
    G.add_node('s1', desc='I am switch 1', attr1='new attr1')
    G.add_node('s2', desc='I am switch 2', attr1='new attr1')
    G.add_node('s3', desc='I am switch 3', attr1='new attr1')
    G.add_edge('s1', 's2', name='edge 0', weight=50)
    G.add_edge('s1', 's3', name='edge 1', weight=100)
    G.add_edge('s2', 's3', name='edge 2', weight=20)

    # draw graph with labels
    pos = nx.spring_layout(G)
    nx.draw(G, pos)

    # generate node_labels manually
    node_labels = {}
    for node in G.nodes:
        node_labels[node] = 'Hello\n I am node: ' + str(node)  # whatever you like

    nx.draw_networkx_labels(G, pos, labels=node_labels)

    nx.draw_networkx_edge_labels(G, pos)  # no edge_labels parameter, default is showing all attributes of edges
    plt.show()


if __name__ == '__main__':
    main()
